<form id="infoaddfm" method="post">
<table border="0" width="100%" cellspacing="1" cellpadding="5" bgcolor="#c4d3e1" style="text-align:left; line-height:18px;">
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">类别：</td>
			<td width="80%">
				<SELECT name="type" id="type" style="width:153px; height:25px;" size='1'>
					<OPTION <?php echo $type==1?'selected':'';?>  value="1">基本信息</OPTION>
					<OPTION <?php echo $type==2?'selected':'';?>  value="2">支付宝信息</OPTION>
					<OPTION <?php echo $type==3?'selected':'';?>  value="3">微信账号</OPTION>
					<OPTION <?php echo $type==4?'selected':'';?>  value="4">七牛CND</OPTION>
					<OPTION <?php echo $type==5?'selected':'';?>  value="5">阿里大于</OPTION>
					<OPTION <?php echo $type==6?'selected':'';?>  value="6">极光推送</OPTION>
				</SELECT>
			</td>
		</tr>
		<tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">名称：</td>
			<td width="80%"><input name="title" id="title" type="text" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入标题.."  required="true"></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">键：</td>
			<td width="80%"><input name="key" id="key" type="text" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入键.."   required="true"></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">值：</td>
			<td width="80%"><textarea name="value" id="value" style="width:450px; height:138px;" class="forminput inputstyle validatebox-text textbox-prompt easyui-validatebox" placeholder="请输入值.." required="true"></textarea></td>
		  </tr>
		  <tr bgcolor="#FFFFFF">
			<td style="line-height:30px;"  width="20%">编码：</td>
			<td width="80%"><label><input id="encode" name="encode" type="checkbox" value="1"> base64</label></td>
		  </tr>
</table>
</form>

<script>
$(function(){
		$('#infoaddsubmit').click(function(data){
				if( $("input:checkbox[name='encode']").is(":checked") ){
						$.base64.utf8encode = true;
						var encodecontent= $.base64.btoa($("#value").val());
						$.post("/admin/index/infoinsert", {"type":$('#type').val(), "title":$('#title').val(), 'key':$('#key').val(), 'value':encodecontent, 'encode':1}, function(data){
								if(data.ret==0){
										$.messager.show({
												title:'提示',
												msg:data.msg,
												timeout:3000,
												showType:'slide'
										});
										$('#infoaddfm').form('clear');
										$("#infodlg").dialog('close');
										$("#info<?php echo $type;?>").datagrid('reload');
								}else{
										$.messager.alert('提示',data.msg,'warning');
								}
						}, 'json');
				}else{
						$('#infoaddfm').form('submit', {
							url:'/admin/index/infoinsert',
							success: function(data){
								var data = eval('(' + data + ')');
								if(data.ret==0){
										$.messager.show({
												title:'提示',
												msg:data.msg,
												timeout:3000,
												showType:'slide'
										});
										$('#infoaddfm').form('clear');
										$("#infodlg").dialog('close');
										$("#info<?php echo $type;?>").datagrid('reload');
								}else{
										$.messager.alert('提示',data.msg,'warning');
								}
							}
						});
				}
		})
});
</script>
